home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 1 / Cream of the Crop 1.iso / PROGRAM / DJLSR106.ARJ / GNULIB.OC < prev    next >
Text File  |  1992-03-02  |  6KB  |  449 lines

  1. /* Subroutines needed by GCC output code on some machines.  */
  2. /* Compile this file with the Unix C compiler!  */
  3.  
  4. /* #include "config.h" */ /*DJ*/
  5.  
  6. /* Define the C data type to use for an SImode value.  */
  7.  
  8. #ifndef SItype
  9. #define SItype long int
  10. #endif
  11.  
  12. /* Define the type to be used for returning an SF mode value
  13.    and the method for turning a float into that type.
  14.    These definitions work for machines where an SF value is
  15.    returned in the same register as an int.  */
  16.  
  17. #ifndef SFVALUE  
  18. #define SFVALUE int
  19. #endif
  20.  
  21. #ifndef INTIFY
  22. #define INTIFY(FLOATVAL)  (intify.f = (FLOATVAL), intify.i)
  23. #endif
  24.  
  25. union flt_or_int { int i; float f; };
  26.  
  27.  
  28. #ifdef L_eprintf
  29. #include <stdio.h>
  30. /* This is used by the `assert' macro.  */
  31. void
  32. __eprintf (string, expression, line, filename)
  33.      char *string;
  34.      char *expression;
  35.      int line;
  36.      char *filename;
  37. {
  38.   fprintf (stderr, string, expression, line, filename);
  39. }
  40. #endif
  41.  
  42. #ifdef L_umulsi3
  43. SItype
  44. __umulsi3 (a, b)
  45.      unsigned SItype a, b;
  46. {
  47.   return a * b;
  48. }
  49. #endif
  50.  
  51. #ifdef L_mulsi3
  52. SItype
  53. __mulsi3 (a, b)
  54.      SItype a, b;
  55. {
  56.   return a * b;
  57. }
  58. #endif
  59.  
  60. #ifdef L_udivsi3
  61. SItype
  62. __udivsi3 (a, b)
  63.      unsigned SItype a, b;
  64. {
  65.   return a / b;
  66. }
  67. #endif
  68.  
  69. #ifdef L_divsi3
  70. SItype
  71. __divsi3 (a, b)
  72.      SItype a, b;
  73. {
  74.   return a / b;
  75. }
  76. #endif
  77.  
  78. #ifdef L_umodsi3
  79. SItype
  80. __umodsi3 (a, b)
  81.      unsigned SItype a, b;
  82. {
  83.   return a % b;
  84. }
  85. #endif
  86.  
  87. #ifdef L_modsi3
  88. SItype
  89. __modsi3 (a, b)
  90.      SItype a, b;
  91. {
  92.   return a % b;
  93. }
  94. #endif
  95.  
  96. #ifdef L_lshrsi3
  97. SItype
  98. __lshrsi3 (a, b)
  99.      unsigned SItype a, b;
  100. {
  101.   return a >> b;
  102. }
  103. #endif
  104.  
  105. #ifdef L_lshlsi3
  106. SItype
  107. __lshlsi3 (a, b)
  108.      unsigned SItype a, b;
  109. {
  110.   return a << b;
  111. }
  112. #endif
  113.  
  114. #ifdef L_ashrsi3
  115. SItype
  116. __ashrsi3 (a, b)
  117.      SItype a, b;
  118. {
  119.   return a >> b;
  120. }
  121. #endif
  122.  
  123. #ifdef L_ashlsi3
  124. SItype
  125. __ashlsi3 (a, b)
  126.      SItype a, b;
  127. {
  128.   return a << b;
  129. }
  130. #endif
  131.  
  132. #ifdef L_divdf3
  133. double
  134. __divdf3 (a, b)
  135.      double a, b;
  136. {
  137.   return a / b;
  138. }
  139. #endif
  140.  
  141. #ifdef L_muldf3
  142. double
  143. __muldf3 (a, b)
  144.      double a, b;
  145. {
  146.   return a * b;
  147. }
  148. #endif
  149.  
  150. #ifdef L_negdf2
  151. double
  152. __negdf2 (a)
  153.      double a;
  154. {
  155.   return -a;
  156. }
  157. #endif
  158.  
  159. #ifdef L_adddf3
  160. double
  161. __adddf3 (a, b)
  162.      double a, b;
  163. {
  164.   return a + b;
  165. }
  166. #endif
  167.  
  168. #ifdef L_subdf3
  169. double
  170. __subdf3 (a, b)
  171.      double a, b;
  172. {
  173.   return a - b;
  174. }
  175. #endif
  176.  
  177. #ifdef L_cmpdf2
  178. SItype
  179. __cmpdf2 (a, b)
  180.      double a, b;
  181. {
  182.   if (a > b)
  183.     return 1;
  184.   else if (a < b)
  185.     return -1;
  186.   return 0;
  187. }
  188. #endif
  189.  
  190. #ifdef L_fixunsdfsi
  191. #define HIGH_BIT_INT_COEFF  (1 << (BITS_PER_WORD - 1))
  192. #define HIGH_BIT_COEFF  (2 * (double) (1 << (BITS_PER_WORD - 2)))
  193.  
  194. SItype
  195. __fixunsdfsi (a)
  196.      double a;
  197. {
  198.   if (a < HIGH_BIT_COEFF)
  199.     return (SItype)a;
  200.   /* Convert large positive numbers to smaller ones,
  201.      then increase again after you have a fixed point number.  */
  202.   else
  203.     return ((SItype) (a - HIGH_BIT_COEFF)) + HIGH_BIT_INT_COEFF;
  204. }
  205. #endif
  206.  
  207. #ifdef L_fixdfsi
  208. SItype
  209. __fixdfsi (a)
  210.      double a;
  211. {
  212.   return (SItype) a;
  213. }
  214. #endif
  215.  
  216. #ifdef L_floatsidf
  217. double
  218. __floatsidf (a)
  219.      SItype a;
  220. {
  221.   return (double) a;
  222. }
  223. #endif
  224.  
  225. #ifdef L_addsf3
  226. SFVALUE
  227. __addsf3 (a, b)
  228.      union flt_or_int a, b;
  229. {
  230.   union flt_or_int intify;
  231.   return INTIFY (a.f + b.f);
  232. }
  233. #endif
  234.  
  235. #ifdef L_negsf2
  236. SFVALUE
  237. __negsf2 (a)
  238.      union flt_or_int a;
  239. {
  240.   union flt_or_int intify;
  241.   return INTIFY (-a.f);
  242. }
  243. #endif
  244.  
  245. #ifdef L_subsf3
  246. SFVALUE
  247. __subsf3 (a, b)
  248.      union flt_or_int a, b;
  249. {
  250.   union flt_or_int intify;
  251.   return INTIFY (a.f - b.f);
  252. }
  253. #endif
  254.  
  255. #ifdef L_cmpsf2
  256. SItype
  257. __cmpsf2 (a, b)
  258.      union flt_or_int a, b;
  259. {
  260.   if (a.f > b.f)
  261.     return 1;
  262.   else if (a.f < b.f)
  263.     return -1;
  264.   return 0;
  265. }
  266. #endif
  267.  
  268. #ifdef L_mulsf3
  269. SFVALUE
  270. __mulsf3 (a, b)
  271.      union flt_or_int a, b;
  272. {
  273.   union flt_or_int intify;
  274.   return INTIFY (a.f * b.f);
  275. }
  276. #endif
  277.  
  278. #ifdef L_divsf3
  279. SFVALUE
  280. __divsf3 (a, b)
  281.      union flt_or_int a, b;
  282. {
  283.   union flt_or_int intify;
  284.   return INTIFY (a.f / b.f);
  285. }
  286. #endif
  287.  
  288. #ifdef L_truncdfsf2
  289. SFVALUE
  290. __truncdfsf2 (a)
  291.      double a;
  292. {
  293.   union flt_or_int intify;
  294.   return INTIFY (a);
  295. }
  296. #endif
  297.  
  298. #ifdef L_extendsfdf2
  299. double
  300. __extendsfdf2 (a)
  301.      union flt_or_int a;
  302. {
  303.   union flt_or_int intify;
  304.   return a.f;
  305. }
  306. #endif
  307.  
  308. #ifdef L_bb_init_func
  309. #if defined (sun) && defined (m68k)
  310. struct bb
  311. {
  312.   int initialized;
  313.   char *filename;
  314.   int *counts;
  315.   int ncounts;
  316.   int zero_word;
  317.   int *addresses;
  318. };
  319.  
  320. __bb_init_function (blocks)
  321.     struct bb *blocks;
  322. {
  323.   extern int __tcov_init;
  324.  
  325.   if (! ___tcov_init)
  326.     ___tcov_init_func ();
  327.  
  328.   ___bb_link (blocks->filename, blocks->counts, blocks->nblocks);
  329. }
  330.  
  331. #endif
  332. #endif
  333.  
  334. /* frills for C++ */
  335.  
  336. #ifdef L_builtin_new
  337. typedef void (*vfp)();
  338.  
  339. extern vfp __new_handler;
  340.  
  341. char *
  342. __builtin_new (sz)
  343.      long sz;
  344. {
  345.   char *p;
  346.  
  347.   p = (char *)malloc (sz);
  348.   if (p == 0)
  349.     (*__new_handler) ();
  350.   return p;
  351. }
  352. #endif
  353.  
  354. #ifdef L_builtin_New
  355. typedef void (*vfp)();
  356.  
  357. static void
  358. default_new_handler ();
  359.  
  360. vfp __new_handler = default_new_handler;
  361.  
  362. char *
  363. __builtin_vec_new (p, maxindex, size, ctor)
  364.      char *p;
  365.      int maxindex, size;
  366.      void (*ctor)();
  367. {
  368.   int i, nelts = maxindex + 1;
  369.   char *rval;
  370.  
  371.   if (p == 0)
  372.     p = (char *)__builtin_new (nelts * size);
  373.  
  374.   rval = p;
  375.  
  376.   for (i = 0; i < nelts; i++)
  377.     {
  378.       (*ctor) (p);
  379.       p += size;
  380.     }
  381.  
  382.   return rval;
  383. }
  384.  
  385. vfp
  386. __set_new_handler (handler)
  387.      vfp handler;
  388. {
  389.   vfp prev_handler;
  390.  
  391.   prev_handler = __new_handler;
  392.   if (handler == 0) handler = default_new_handler;
  393.   __new_handler = handler;
  394.   return prev_handler;
  395. }
  396.  
  397. vfp
  398. set_new_handler (handler)
  399.      vfp handler;
  400. {
  401.   return __set_new_handler (handler);
  402. }
  403.  
  404. static void
  405. default_new_handler ()
  406. {
  407.   /* don't use fprintf (stderr, ...) because it may need to call malloc.  */
  408.   write (2, "default_new_handler: out of memory... aaaiiiiiieeeeeeeeeeeeee!\n", 65);
  409.   /* don't call exit () because that may call global destructors which
  410.      may cause a loop.  */
  411.   _exit (-1);
  412. }
  413. #endif
  414.  
  415. #ifdef L_builtin_del
  416. typedef void (*vfp)();
  417.  
  418. void
  419. __builtin_delete (ptr)
  420.      char *ptr;
  421. {
  422.   if (ptr)
  423.     free (ptr);
  424. }
  425.  
  426. void
  427. __builtin_vec_delete (ptr, maxindex, size, dtor, auto_delete_vec, auto_delete)
  428.      char *ptr;
  429.      int maxindex, size;
  430.      void (*dtor)();
  431.      int auto_delete;
  432. {
  433.   int i, nelts = maxindex + 1;
  434.   char *p = ptr;
  435.  
  436.   ptr += nelts * size;
  437.  
  438.   for (i = 0; i < nelts; i++)
  439.     {
  440.       ptr -= size;
  441.       (*dtor) (ptr, auto_delete);
  442.     }
  443.  
  444.   if (auto_delete_vec)
  445.     free (p);
  446. }
  447.  
  448. #endif
  449.